package com.huangpuweb.task.service.imp;

import com.huangpuweb.task.model.QzYYGFData;
import com.huangpuweb.task.model.QzYYGFDataRowMapper;
import com.huangpuweb.task.service.SyncQzYYGFDataService;
import org.springframework.stereotype.Service;

@Service
public class SyncQzYYGFDataServiceImp extends BaseQzYYGFdataServiceImp implements SyncQzYYGFDataService {


    @Override
    public QzYYGFData getQzYYGFData(String startTime, String endTime, String yygfspotcode) {
//        String sql="select SUM(InSum)-SUM(OutSum) as 'realTimeNum',SUM(InSum) as 'sum',max(CountDate) as 'CountDate' from intsummary_base where CountDate >=? and CountDate<=? and SiteKey=?";
//        return getEntry(sql,new QzYYGFDataRowMapper(),new Object[]{startTime,endTime,yygfspotcode});

        //greatest(ifnull(sum(InSum),0)-ifnull(sum(OutSum),0),0) from intsummary_base
        //select greatest(ifnull(sum(InSum),0)-ifnull(sum(OutSum),0),0) as 'realTimeNum',SUM(InSum) as 'sum',max(CountDate) as 'CountDate' from intsummary_base where CountDate >=? and CountDate<=?
        //String sql="select SUM(InSum)-SUM(OutSum) as 'realTimeNum',SUM(InSum) as 'sum',max(CountDate) as 'CountDate' from intsummary_base where CountDate >=? and CountDate<=? and SiteKey=700  and SiteName not in ('张铁军正门','沉香阁正门')";


        String sql="select greatest(ifnull(sum(InSum),0)-ifnull(sum(OutSum),0),0) as  'realTimeNum',SUM(InSum) as 'sum',max(CountDate) as 'CountDate' from intsummary_base where 1=1 and CountDate between ? and ? and SiteType = 700 and SiteName not in ('张铁军正门','沉香阁正门')";
        return getEntry(sql,new QzYYGFDataRowMapper(),new Object[]{startTime,endTime});
    }
}
